package com.jjty.dataGenerator.common;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jjty.dataGenerator.exception.ServiceException;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: huangyulong
 * @createTime: 2023-04-07 15:26
 * @Description:
 */
public class PageParamReader {

    public static Page read(HttpServletRequest request){

        String index = request.getParameter("index");
        String size = request.getParameter("size");

        if(StringUtils.isBlank(index) || StringUtils.isBlank(size)){
            throw new ServiceException("分页参数不正确");
        }

        return new Page(Integer.valueOf(index),Integer.valueOf(size));
    }

}
